package org.pearl.tactuator.endpoint;

import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.Selector;
import org.springframework.boot.actuate.endpoint.web.annotation.WebEndpoint;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by TD on 2021/8/13
 */
@Component
// 自定义一个WEB访问端点，ID为唯一标识，
@WebEndpoint(id = "testEndpoint")
public class TestEndpoint {

    // 读操作，对应GET请求
    @ReadOperation
    public Map<String, String> test( @Selector(match = Selector.Match.ALL_REMAINING)  String name) {
        Map<String, String> result = new HashMap<String, String>();
        result.put("version", "1.0.0");
        result.put("author", name);
        return result;
    }

    @ReadOperation
    public String test2(@Selector String aaa) {
        return "result";
    }

/*
    @ReadOperation
    public Map<String, String> test2(@Selector String v2) {
        Map<String, String> result = new HashMap<String, String>();
        result.put("version", "2.0.0");
        result.put("author", "zhang san");
        return result;
    }


    @ReadOperation
    public Map<String, String> test3(@Selector(match = Selector.Match.ALL_REMAINING) String v3) {
        Map<String, String> result = new HashMap<String, String>();
        result.put("version", "3.0.0");
        result.put("author", "zhang san");
        return result;
    }*/
}
